/*--------------------------------------------------------------------------------*/
#ifndef __APPLICATION_H__
#define __APPLICATION_H__
/*--------------------------------------------------------------------------------*/
#include "primitives.h"
#include "text.h"
#include "timer.h"
#include "defs.h"
#include "color.h"
#include "component_state_chart.h"
#include <SDL/SDL.h>
#include <GL/glu.h>
/*--------------------------------------------------------------------------------*/
class APPLICATION
	: public OBJECT
{
	// -- PUBLIC

public:

    DECLARE_REF( APPLICATION );
    DECLARE_SINGLETON( APPLICATION );

	// .. CONSTRUCTORS

					APPLICATION();
					virtual ~APPLICATION();
	// .. METHODS

	VOID            Initialize( const BOOL fullscreen, const BOOL create_all_instances = true );
	VOID            Start();
	VOID            StartUsingStateChart( const COMPONENT_STATE_CHART * state_chart );
	VOID			Quit();
	VOID            SetName( const TEXT & name );
	VOID            SetExtent( const INT & width, const INT & height );
	VOID            SetRenderCallBack( VOID ( *call_back )() );
	VOID            SetUpdateCallBack( VOID ( *call_back )( const TIMER & time_step  ) );
	VOID			SetClearColor( const COLOR & color );

	// -- PRIVATE

private:

	// .. METHODS
  
	VOID			End();
	VOID            EnableMode2d();
	VOID            ( * RenderCallBack )();
	VOID            ( * UpdateCallBack )( const TIMER & time_step );

	// .. ATTRIBUTES

	BOOL
		ItIsRunning;
	UINT
		Width,
		Height;
	TEXT
		Name;
	SDL_Surface
		*RenderSurface;
};
/*--------------------------------------------------------------------------------*/
#define APPLICATION_Initialize						APPLICATION::GetInstance().Initialize
#define APPLICATION_Start							APPLICATION::GetInstance().Start
#define APPLICATION_StartUsingStateChart			APPLICATION::GetInstance().StartUsingStateChart
#define APPLICATION_Quit							APPLICATION::GetInstance().Quit
#define APPLICATION_SetName							APPLICATION::GetInstance().SetName
#define APPLICATION_SetExtent						APPLICATION::GetInstance().SetExtent
#define APPLICATION_SetRenderCallBack   			APPLICATION::GetInstance().SetRenderCallBack
#define APPLICATION_SetUpdateCallBack   			APPLICATION::GetInstance().SetUpdateCallBack
#define APPLICATION_SetClearColor	    			APPLICATION::GetInstance().SetClearColor
/*--------------------------------------------------------------------------------*/
#endif
/*--------------------------------------------------------------------------------*/
